#include<bits/stdc++.h>
using namespace std;
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	srand(time(0));
	for(int i=0;i<rand();i++)srand(rand());
	int T;
	cin>>T;
	while(T--)
	{
		int n,m,L,V,d[200000],v[200000],a[200000],p[200000],skip[200000],cursor=0,ans=0;
		cin>>n>>m>>L>>V;
		for(int i=0;i<n;i++)
		{
			cin>>d[i]>>v[i]>>a[i];
			if(v[i]<=V&&a[i]<=0)skip[cursor++]=i;
		}
		for(int i=0;i<m;i++)
		{
			cin>>p[i];
			for(int j=0;j<n;j++)
			{
				for(int k=0;k<cursor;k++)if(skip[k]==j)goto END;
				if(d[j]>p[i])continue;
				if(d[j]==p[i])
				{
					if(v[j]>V)
					{
						ans++;
						skip[cursor++]=j;
					}
					continue;
				}
				if(sqrt(v[j]*v[j]+2*a[j]*(p[i]-d[j]))>(double)V)
				{
					ans++;
					skip[cursor++]=j;
				}
			}
			END:;
		}
		cout<<ans<<" "<<rand()%m<<endl;
	}
	return 0;
}
